#pragma once

#ifndef _CACTIONPACKET_H_
#define _CACTIONPACKET_H_

#include "CBasicPacket.h"
#include <vector>

/*
enum ActionPacketCategories
{
   mone = 0,
   attack1,
   attack2,
   weaponskill_end,
   magic_end,
   item_end,
   jobskill_end,
   weaponskill_start,
   magic_start,
   item_start,
   jobskill_start,
   unknown1,
   unknown2,
   unknown3,
   unknown4,
   unknown5
};
*/

struct apActionEntry
{
	unsigned char unknownValue; // 5 bits
	unsigned short targetAnimationID; // 10 bits
	unsigned short unknownValue2; // 10 bits 
	unsigned short parameter2; // 16 bits
	unsigned short messageType; // 10 bits
	unsigned int additionalMessages; //32 bits;
	unsigned char dynamisTimerFlag; //2 bits;
};

struct apTargetEntry
{
	unsigned int m_targetID;
	std::vector<apActionEntry*> m_actions;
};

class CActionPacket : public CBasicPacket
{
private:
	unsigned char calculateWorkloadSize(void);

	std::vector<apTargetEntry*> m_targets;

	unsigned int m_actorCharId;
	unsigned char m_categorie;
	unsigned short m_param1;
	unsigned char m_startAnimCategorie;
	unsigned short m_startAnimation;
	unsigned int m_unknownValue;

public:
	CActionPacket();
	~CActionPacket(void);

	bool loadPremade(int packetNum);
	bool loadPremade(unsigned int charId,unsigned int targId, int packetNum);
	bool loadPremade(int packetNum, bool fixCounterInSource);

	void setActorId(unsigned int actorCharId);
	void setCategorie(unsigned char categorie);
	void setParameter1(unsigned short param1);
	void setStartAnimationCategorie(unsigned char startAnimCategorie);
	void setStartAnimation(unsigned short startAnimation);
	void setUnknown(unsigned int unknownValue);

	void setTargetID(unsigned char targetNum, unsigned int targetID);
	void setActionEntry(unsigned short targetNum, unsigned char actionNum, apActionEntry* newEntry);

	unsigned char getNumberOfTargets(void);
	unsigned char getNumberOfActionsForTarget(unsigned char numTarget);

	void finalizePacket(void);

	void savePacket(void);
	void savePacket(int num);
	void savePacket(char* filename);
};
#endif

